<?php
/*
* Category Template: Bản đồ
*/
?>
<?php get_header() ?>
<?php
$option = get_option('tvpresident_1_settings');
$cat = get_query_var('cat');
$catname = get_cat_name($cat); 
?>
<div id="content">
        <div class="ngangborder"></div>
        <div class="left-content">
        <div class="divlist">
		<div class="divtitle"><?php echo $catname; ?></div>
          <?php
              wp_reset_query();
              $posts_per_page = 20;
              $page = (get_query_var('page')) ? get_query_var('page') : 1;
              $cat = get_query_var('cat');
              query_posts(array('cat' => $cat,'posts_per_page'=>$posts_per_page,'page' => $page, 'offset' => $posts_per_page*($page-1)));
              global $wp_query;
              $pagination = paginate_links( array(
                  'current' =>  max( 1,get_query_var('page')),
                  'total' => $wp_query->max_num_pages,
                  'type' => 'array',
                  'next_text' => '»',
                  'prev_text' => '«'
              ) );
              ?>
              <?php if(isset($pagination)){ 
                $pagination = str_replace("href=''", "href='".get_category_link('')."?page=1'", $pagination);
                $pagination = str_replace('href=""', 'href="'.get_category_link('').'?page=1"', $pagination);
                ?>
                <div class="pagination">
                  <?php foreach($pagination as $page){  ?>
                     <?php echo $page; ?>
                  <?php } ?>
                </div>
              <?php } ?>

          <div class="ngangborder"></div>
          <div class="listuser" style="margin-top: 10px;">
            <?php
              while (have_posts()): the_post(); 
              if(get_cat_slug(get_category($cat)->category_parent)!='business'){
                global $post;
                $currCat = get_the_category($post->ID);
                foreach($currCat as $key=>$value){
                  if(get_cat_slug($value->category_parent)!='business') unset($currCat[$key]);
                }
                $currCat = array_values($currCat);
                $catName = $currCat[0]->cat_name;
              } else {
                $catName = get_cat_name($cat);
              }
              ?>
                  <div class="user">
                    <div class="img"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(100,100),array('style'=>'width:100px;height:100px;')); ?></a></div>
                    <div class="usercontent">
                    <span class="name"><?php the_title(); ?></span><br>
                    <span class="job"><?php echo $catName; ?></span><br>
                    </div>
                    <div style="clear:both;"></div>
                </div>
             <?php endwhile; ?>
            <div style="clear:both;"></div>
          </div>

            <?php if(isset($pagination)){ ?>
              <div class="pagination">
                <?php foreach($pagination as $page){  ?>
                   <?php echo $page; ?>
                <?php } ?>
              </div>
            <?php } ?>
            </div>
        </div>
        <div class="right-content">
          <?php get_sidebar() ?>
        </div>
        <div style="clear:both"></div>
      </div>
      <div style="clear:both;"></div>
<?php get_footer() ?>